home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 24 / CU Amiga Magazine's Super CD-ROM 24 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-07].iso / CUCD / Programming / SWI / source / src / pl-buffe.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-18  |  793 b   |  43 lines

  1. /*  $Id: pl-buffe.c,v 1.1 1995/04/18 12:29:03 jan Exp $
  2.  
  3.     Part of XPCE
  4.     Designed and implemented by Anjo Anjewierden and Jan Wielemaker
  5.     E-mail: jan@swi.psy.uva.nl
  6.  
  7.     Copyright (C) 1993 University of Amsterdam. All rights reserved.
  8. */
  9.  
  10. #include "pl-incl.h"
  11. #include "pl-buffer.h"
  12.  
  13. Buffer
  14. newBuffer(void)
  15. { Buffer b = allocHeap(sizeof(buffer));
  16.   
  17.   initBuffer(b);
  18.   return b;
  19. }
  20.  
  21.  
  22. void
  23. freeBuffer(Buffer b)
  24. { discardBuffer(b);
  25.   freeHeap(b, sizeof(buffer));
  26. }
  27.  
  28.  
  29. void
  30. growBuffer(Buffer b, long int minfree)
  31. { long sz = b->max - b->base;
  32.   long top = b->top - b->base;
  33.  
  34.   sz = (sz ? ROUND((sz * 3) / 2, 512) : 512);
  35.  
  36.   b->base = (b->base ? realloc(b->base, sz) : malloc(sz));
  37.   if ( !b->base )
  38.     fatalError("Not enough memory");
  39.  
  40.   b->top = b->base + top;
  41.   b->max = b->base + sz;
  42. }
  43.